﻿


(function ($) {

    $.fn.sQevent = function (options) {
        options = $.extend({}, $.fn.sQevent.defaultOptions, options);
        
        this.each(function () {
            var element = $(this);
            //var btnAction = (typeof options.btnAction == 'function') ? options.btnAction : function () { };
            var prefix = options.title.replace(/ /g, '').toLowerCase();

            var markup = "";
            markup += '<div class="unliq-event" id="' + prefix + '-unliq-event">'
            markup += '<div class="title" parent="' + prefix + '"><div class="float-left" style="width: 89%;">' + options.title + '</div><div parent="' + prefix + '" id="' + prefix + '-close-btn" class="float-left fui-cross-16 close-btn" style="cursor:pointer"></div></div>'
            markup += '<div class="current-num" id="' + prefix + 'current-num">You are not yet in Q.</div>'
            markup += '<div class="desc">'
            markup += '<ul>'
            markup += '<li><div class="float-left">Person in charge:</div><div class="float-left" style="font-weight:bold">'+ options.personincharge +'</div></li>'
            markup += '<li><div class="float-left">Room:</div><div class="float-left" style="font-weight:bold">'+ options.room +'</div></li>'
            markup += '</ul>'
            markup += '</div>'
            markup += '<div class="nums">'
            markup += '<div class="onq">'
            markup += '<div class="onq-title">On Q</div>'
            markup += '<div class="onq-num" id="' + prefix + 'onq-num">15</div>'
            markup += '</div>'
            markup += '<div class="nowserving">'
            markup += '<div class="nowserving-title">Now Serving</div>'
            markup += '<div class="nowserving-num" id="' + prefix + 'nowserving-num">05</div>'
            markup += '</div>'
            markup += '<div style="clear:both"></div>'
            markup += '</div>'
            markup += '<div class="event-btns">'
            markup += '<input type="button" class="btn btn-info  event-btn" id="' + prefix + 'btn-res" value="Reserve" eventname="' + prefix + '"/>'
            markup += '<div type="button" class="btn btn-info btn-prntr" id="' + prefix + 'btn-prnt" ></div>'
            markup += '<div style="clear:both"></div>'
            markup += '</div>'
            markup += '</div>'
            
            element.html(markup);

            $('#' + prefix + 'btn-res').click(function () {
                var nxtQ = parseInt($('#' + prefix + 'onq-num').html()) + 1;
                $('#'+ prefix + 'current-num').html('You are number <b id="b-idnum">' + nxtQ + '</b> in Q.')
                
            })

            $('#'+ prefix + '-close-btn').click(function () {
                $('#' + prefix + '-unliq-event').remove();
            })
        });

        return this;
    }
})(jQuery);